import { postLoginWxMinSimple } from "@/api/profile";

export default {
  // 命名空间
  namespaced: true,
  state: {
    profile: null,
  },
  getters: {},
  mutations: {
    // this.$store.commit('setProfile', 123)
    setProfile(state, payload) {
      console.log("payload -----> ", payload);
      state.profile = payload;
    },
  },
  // mutations 是同步修改的代码
  // actions 异步代码在actions执行
  actions: {
    // 手机号登录
    // this.$store.dispatch('postLoginWxMinSimple', 123)
    async postLoginWxMinSimple(store, payload) {
      const res = await postLoginWxMinSimple(payload);
      store.commit("setProfile", res.result);
    },
  },
};
